package client.gui.workbox;

import client.network.ServiceRequestCenter;
import client.network.interactive.JoinRoomByNameRequest;

public class WorkBoxController {
  
  private final ServiceRequestCenter servicer_;
  private final WorkBoxDisplay view_;
  private final WorkBoxModel model_;
  
  public WorkBoxController(String title, ServiceRequestCenter servicer, WorkBoxModel model) {
    assert servicer != null && model != null && title != null;
    servicer_ = servicer;
    view_ = new WorkBoxDisplay(title, this);
    model.addListener(view_);
    
    model_ = model;
  }
  
  public boolean isVisible() {
    return view_.isVisible();
  }
  
  public void setVisible(boolean status) {
    view_.setVisible(status);
  }
  
  public void requestNewRoom(String roomname) {
    servicer_.requestNewRoom(roomname);
  }
  
  public void requestNewPrivatePersistentRoom(String roomname) {
    servicer_.requestNewPrivatePersistentRoom(roomname);
  }
  
  public void requestJoinRoom(String roomname) {
    servicer_.serviceRequest(new JoinRoomByNameRequest(roomname));
  }
  
  public void cleanUp() {
    model_.cleanUp();
    servicer_.cleanUp();
  }
  
}
